import httpRequest from '@/config/axios/httpRequest'
import {
  BpmCategoryCreateReq,
  BpmCategoryCreateResp,
  BpmCategoryDeleteReq,
  BpmCategoryDeleteResp,
  BpmCategoryGetResp,
  BpmCategoryPageReq,
  BpmCategoryPageResp,
  BpmCategorySortReq,
  BpmCategorySortResp,
  BpmCategoryUpdateReq,
  BpmCategoryUpdateResp
} from '@/models/bpm/BpmCategoryModel'
import bpmapi from '../bpmapi'

// BPM 流程分类 API
export const CategoryApi = {
  // 查询流程分类分页
  getCategoryPage: async (params: BpmCategoryPageReq) => {
    return await httpRequest.get<BpmCategoryPageResp>(bpmapi.BpmCategoryPage, { params })
  },

  // 查询流程分类详情
  getCategory: async (id: number) => {
    return await httpRequest.get<BpmCategoryGetResp>(bpmapi.BpmCategoryGet, { params: { Id: id } })
  },

  // 新增流程分类
  createCategory: async (data: BpmCategoryCreateReq) => {
    return await httpRequest.post<BpmCategoryCreateResp>(bpmapi.BpmCategoryCreate, data)
  },

  // 修改流程分类
  updateCategory: async (data: BpmCategoryUpdateReq) => {
    return await httpRequest.put<BpmCategoryUpdateResp>(bpmapi.BpmCategoryUpdate, data)
  },

  // 批量修改流程分类的排序
  updateCategorySortBatch: async (data: BpmCategorySortReq) => {
    return await httpRequest.put<BpmCategorySortResp>(bpmapi.BpmCategoryUpdateSortBatch, data)
  },

  // 删除流程分类
  deleteCategory: async (data: BpmCategoryDeleteReq) => {
    return await httpRequest.delete<BpmCategoryDeleteResp>(bpmapi.BpmCategoryDelete, { data })
  }
}
